package com.yuju.controller.hotel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.yuju.common.PageModel;
import com.yuju.common.Result;
import com.yuju.controller.base.BaseController;
import com.yuju.enums.ReturnCodeEnum;
import com.yuju.enums.ReturnStatusEnum;
import com.yuju.hotel.enums.LogRoomRecordReturnCodeEnum;
import com.yuju.log.model.LogRoomRecordModel;
import com.yuju.log.service.ILogRoomRecordService;
import com.yuju.util.Utils;
import com.yuju.vo.hotel.LogRoomRecordVO;

@Controller
@RequestMapping("logRoomRecord")
public class LogRoomRecordController extends BaseController<LogRoomRecordVO, LogRoomRecordModel> {
	
	@Autowired
	private ILogRoomRecordService logRoomRecordService;
	
	
	@RequestMapping("list")
	@ResponseBody
	public Result list(@RequestBody JSONObject obj) {
		LogRoomRecordVO logRoomRecordVO = obj.toJavaObject(LogRoomRecordVO.class);
		Result result = new Result();
		PageModel pageModel = logRoomRecordService.pageList(convert(logRoomRecordVO), logRoomRecordVO.getPage(), logRoomRecordVO.getPageSize());
		if (Utils.isNotNull(pageModel) && Utils.isNotNull(pageModel.getRows())) {
			result.setPageModel(pageModel);
			result.setStatus(ReturnStatusEnum.SUCCESS.getCode());
			result.setMsg(ReturnStatusEnum.SUCCESS.getDesc());
			result.setReturnCode(LogRoomRecordReturnCodeEnum.LOG_QUERY_SUCCESS.getCode());
			result.setReturnMsg(LogRoomRecordReturnCodeEnum.LOG_QUERY_SUCCESS.getDesc());
		} else {
			result = new Result();
			result.setStatus(ReturnStatusEnum.FAILURE.getCode());
			result.setMsg(ReturnStatusEnum.FAILURE.getDesc());
			result.setReturnCode(ReturnCodeEnum.NO_DATA.getCode());
			result.setReturnMsg(ReturnCodeEnum.NO_DATA.getDesc());
		}
		return result;
	}
}
